package edu.gyc.objecthomework;/*
 * PersonAddress.java
 *
 * Created on February 15, 2007, 4:09 PM
 *
 * Solution to Exercise 8
 */

/**
 *
 * @author charleshoot
 */

import java.util.Scanner;

public class PersonAddress {
    
    
    
    
    private String firstName;
    private String lastName;
    private String emailAddress;
    private String phoneNumber;
    
    
    
    public void initialize(String first, String last, String email, String phone) {
        firstName = first;
        lastName = last;
        emailAddress = email;
        phoneNumber = phone;
    }
    
    
    
    public String getFirstName(){
        return firstName;
    }
    
    public String getLastName(){
        return lastName;
    }
    
    public String getEmailAddress(){
        return emailAddress;
    }
    
    public String getPhoneNumber(){
        return phoneNumber;
    }
    
    public void updateEmail(String newEmail){
        emailAddress = newEmail;
    }
    
    public void updatePhone(String newPhone){
        phoneNumber = newPhone;
    }
    
    public boolean equal(PersonAddress otherPerson){
        return lastName.equals(otherPerson.lastName) &&
                firstName.equals(otherPerson.firstName);
    }
    
    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        PersonAddress person1 = new PersonAddress();
        PersonAddress person2 = new PersonAddress();
        PersonAddress person3 = new PersonAddress();
        person1.initialize("Joe", "Henry", "jhenry@bix.net", "555-3456");
        person2.initialize("Joe", "Henry", "jh@bbb.com", "555-4356");
        person3.initialize("Sue", "Henry", "sh@bbb.com", "555-4356");
        
        System.out.println("Get the attributes for person 1.");
        System.out.println(" NAME: " + person1.getFirstName()
        + " " + person1.getLastName()
        + " EMAIL: " + person1.getEmailAddress()
        + " PHONE: " + person1.getPhoneNumber()
        );
        System.out.println();
        
        System.out.println("person 1 should be equal to person 2");
        System.out.println(person1.equal(person2));
        System.out.println();
        
        System.out.println("person 2 should not be equal to person 3");
        System.out.println(person2.equal(person3));
        System.out.println();
        
        System.out.println("Changing the email of person 1 to \"email@bob\"");
        System.out.println("Changing the phone of person 1 to \"555-1111\"");
        person1.updateEmail("email@bob");
        person1.updatePhone("555-1111");
        System.out.println(" NAME: " + person1.getFirstName()
        + " " + person1.getLastName()
        + " EMAIL: " + person1.getEmailAddress()
        + " PHONE: " + person1.getPhoneNumber()
        );
        System.out.println();
        
        
        
    }
    
}




